<extend name="Public:base" />

<block name="additional-styles">
	<!-- daterange picker -->
	<link rel="stylesheet" href="__PUBLIC__/Admin/plugins/daterangepicker/daterangepicker-bs3.css">
</block>

<block name="content-wrapper">
	<!-- Content Wrapper. Contains page content -->
	<div class="content-wrapper">
		<!-- Content Header (Page header) -->
		<section class="content-header">
			<h1>
				修改作业
				<small>Modify Homework</small>
			</h1>
			<ol class="breadcrumb">
				<li>
					<a href="{:U('Index/index')}"> <i class="fa fa-dashboard"></i>
						首页
					</a>
				</li>
				<li>
					<a href="{:U('Homework/index')}">作业列表</a>
				</li>
				<li class="active">修改作业</li>
			</ol>
		</section>

		<!-- Main content -->
		<section class="content">
			<div class="row">
				<div class="col-sm-6 col-sm-offset-3">
					<div class="box">
						<div class="box-header with-border">
							<h3 class="box-title">表单</h3>
						</div>
						<!-- /.box-header -->
						<!-- form start -->
						<div class="box-body">
							<form id="form-modify" class="form-horizontal" action="{:U('Homework/modifyPost')}" method="post">
								<input name="id" id="id" type="hidden" value="{$homework.id}">
								<div class="form-group">
									<label class="col-sm-2 control-label">标题</label>
									<div class="col-sm-9">
										<input name="title" id="title" type="text" class="form-control" value="{$homework.title}">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label">内容</label>
									<div class="col-sm-9">
										<textarea name="content" id="content" class="form-control">{$homework.content}</textarea>
									</div>
								</div>
								<php>
									$start_time = date('Y/m/d H:i', $homework['start_time']);
									$end_time = date('Y/m/d H:i', $homework['end_time']);
								</php>
								<div class="form-group">
									<label class="col-sm-2 control-label">有效时间</label>
									<div class="col-sm-9">
										<input id="active_time" type="text" class="form-control" value="{$start_time} - {:$end_time}">
						            </div>
								</div>
								<input name="start_time" id="start_time" type="hidden" value="{$start_time}">
								<input name="end_time" id="end_time" type="hidden" value="{$end_time}">
								<div class="form-group">
									<label class="col-sm-2 control-label">逻辑班级</label>
									<div class="col-sm-9">
										<select name="logic_class_id" id="logic_class_id" class="form-control">
											<volist name="logic_classes" id="vo">
												<eq name="vo.id" value="$homework.logic_class.id">
													<option value="{$vo.id}" selected="selected">{$vo.name}</option>
												<else />
													<option value="{$vo.id}">{$vo.name}</option>
												</eq>																								
											</volist>
						                 </select>
									</div>
								</div>
							</form>
						</div>
						<!-- /.box-body -->
						<div class="box-footer">
							<a href="{:U('Homework/index')}" type="button" class="btn btn-default">返回</a>
							<button id="button-modify-submit" type="button" class="btn btn-info pull-right">确定</button>
						</div>
						<!-- /.box-footer -->
					</div>				
				</div>				
			</div>
		</section>
		<!-- /.content -->
	</div>
	<!-- /.content-wrapper -->
</block>

<block name="additional-scripts">
	<!-- date-range-picker -->
	<script src="__PUBLIC__/Admin/plugins/daterangepicker/moment.min.js"></script>
	<script src="__PUBLIC__/Admin/plugins/daterangepicker/daterangepicker.js"></script>
	<script>
		$(function () {
			//Date range picker with time picker
			$('#active_time').daterangepicker({
				timePicker: true,
				timePickerIncrement: 1,
				format: 'YYYY/MM/DD HH:mm',
			    "locale": {
			        "separator": " - ",
			        "applyLabel": "确定",
			        "cancelLabel": "取消",
			        "fromLabel": "开始日期",
			        "toLabel": "截止日期",
			        "customRangeLabel": "Custom",
			        "daysOfWeek": [
			            "日",
			            "一",
			            "二",
			            "三",
			            "四",
			            "五",
			            "六"
			        ],
			        "monthNames": [
			            "1月",
			            "2月",
			            "3月",
			            "4月",
			            "5月",
			            "6月",
			            "7月",
			            "8月",
			            "9月",
			            "10月",
			            "11月",
			            "12月"
			        ],
			        "firstDay": 1
			    },
			});

			$('#button-modify-submit').click(function() {
				var active_time = $('#active_time').val();
				var time_array = active_time.split('-');
				$('#start_time').val(time_array[0]);
				$('#end_time').val(time_array[1]);
				$('#form-modify').submit();
			});
		});
	</script>
</block>